#include <bits/stdc++.h>
using namespace std;

int main() {
    int T;
    scanf("%d", &T);
    int kase = 0;
    while (T--) {
        kase++;
        int n, k, s;
        scanf("%d%d%d", &n, &k, &s);
        int ans = min(n, k - s + n - s) + k;
        printf("Case #%d: %d\n", kase, ans);
    }
}